package org.Image.management.utils.remind;

import javax.swing.*;
import java.awt.*;
import java.net.URL;
import java.util.function.Consumer;

public class ShowDialogUtils {
    /**
     * 创建一个图片提示框
     *
     * @param wide            - 宽度
     * @param high            - 高度
     * @param background      - 背景图片
     * @param time            - 关闭时间
     * @param isOffAnimations - 是否关闭动画 true 关闭动画 false 不关闭动画 默认 false 不关闭动画
     * @param consumer        - 关闭时触发的回调函数
     * @return ShowDialog - 提示框类 对象
     */
    public static ShowDialogImages ShowDialogBuilder(int wide, int high, Image background, int time, boolean isOffAnimations, Consumer<Long> consumer) {
        ShowDialogImages showDialogImages = DialogBuilder(wide, high, background);
        showDialogImages.CloseThread(time, isOffAnimations, consumer);
        return showDialogImages;
    }

    public static ShowDialogImages ShowDialogBuilder(int wide, int high, Image background, int time, Consumer<Long> consumer) {
        return ShowDialogBuilder(wide, high, background, time, false, consumer);
    }

    public static ShowDialogImages ShowDialogBuilder(int wide, int high, Image background, int time) {
        return ShowDialogBuilder(wide, high, background, time, null);
    }

    public static ShowDialogImages ShowDialogBuilder(int wide, int high, Image background) {
        return ShowDialogBuilder(wide, high, background, 0);
    }

    public static ShowDialogImages ShowDialogBuilder(int wide, int high, URL background, int time, boolean isOffAnimations, Consumer<Long> consumer) {
        return ShowDialogBuilder(wide, high, new ImageIcon(background).getImage(), time, isOffAnimations, consumer);
    }

    public static ShowDialogImages ShowDialogBuilder(int wide, int high, URL background, int time, Consumer<Long> consumer) {
        return ShowDialogBuilder(wide, high, background, time, true, consumer);
    }

    public static ShowDialogImages ShowDialogBuilder(int wide, int high, URL background, int time) {
        return ShowDialogBuilder(wide, high, background, time, null);
    }

    public static ShowDialogImages ShowDialogBuilder(int wide, int high, URL background) {
        return ShowDialogBuilder(wide, high, background, 0);
    }


    /**
     * 创建一个图片提示框 不会自动关闭 需要手动关闭
     *  方法为 showDialog.ClosePrompt(consumer); 或 （有关闭动画） showDialog.CloseAnimationPrompt(consumer);
     * @param wide       - 宽度
     * @param high       - 高度
     * @param background - 背景图片
     * @return ShowDialog - 提示框类 对象
     */
    public static ShowDialogImages DialogBuilder(int wide, int high, Image background) {
        ShowDialogImages showDialogImages = new ShowDialogImages(wide, high, background);
        new Thread(showDialogImages::show).start();
        return showDialogImages;
    }

    public static ShowDialogImages DialogBuilder(int wide, int high, URL background) {
        return DialogBuilder(wide, high, new ImageIcon(background).getImage());
    }
}
